package cn.tedu.api;

import java.util.Objects;

public class Animal {
    public static void main(String[] args) {
        Animal1 a = new Animal1("胖橘",3);
        Animal1 a1 = new Animal1("胖橘",3);
        System.out.println(a);
        System.out.println(a.hashCode());
        System.out.println(a.equals(a1));
    }
}
class Animal1{
    String name;
    int age ;
    public Animal1() {
    }
    public Animal1(String name, int age) {
        this.name = name;
        this.age = age;
    }

    @Override
    public String toString() {
        return "Animal1{" +
                "name='" + name + '\'' +
                ", age=" + age +
                '}';
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Animal1 animal1 = (Animal1) o;
        return age == animal1.age &&
                Objects.equals(name, animal1.name);
    }

}